package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.DevlopmentDomainAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 部署域属性联动处理类
 */
@Service
@AttrHandler(DevlopmentDomainAttrHandler.class)
public class DevelopmentDomainAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    @Override
    public void handle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {
        //互联网EIP（个数）
        KiteAttr netEIpCountAttr = kiteInst.getAttr("210003823");
        //互联网地址（带宽）
        KiteAttr netAddrAttr = kiteInst.getAttr("210003824");


        if (KiteStringUtils.equals("100005310", kiteAttr.getValue())) {
            if (Objects.nonNull(netEIpCountAttr)) {
                netEIpCountAttr.setIsNull(KeyConsts.IFTRUE_F);
                if(KiteStringUtils.equals(kiteInst.getSpecId(),"1003538")){
                    netEIpCountAttr.setShowType("D");
                }
            }

            if (Objects.nonNull(netAddrAttr)) {
                netAddrAttr.setIsNull(KeyConsts.IFTRUE_F);
                if(KiteStringUtils.equals(kiteInst.getSpecId(),"1003538")){
                    netAddrAttr.setShowType("D");
                }
            }
        } else {
            if (Objects.nonNull(netEIpCountAttr)) {
                netEIpCountAttr.setIsNull(KeyConsts.IFTRUE_T);
                if(KiteStringUtils.equals(kiteInst.getSpecId(),"1003538")){
                    netEIpCountAttr.setShowType("M");
                }
            }
            if (Objects.nonNull(netAddrAttr)) {
                netAddrAttr.setIsNull(KeyConsts.IFTRUE_T);
                if(KiteStringUtils.equals(kiteInst.getSpecId(),"1003538")){
                    netAddrAttr.setShowType("M");
                }
            }

        }
    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
